package com.quasar.hpatient.model.operationmodel;

import android.content.ContentValues;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.HttpResult;
import com.quasar.hpatient.model.litePalmodel.Aerainfodb;
import com.quasar.hpatient.model.litePalmodel.BaseInfoVersiondb;
import com.quasar.hpatient.model.litePalmodel.BloodTypeInfodb;
import com.quasar.hpatient.model.litePalmodel.BodyInfodb;
import com.quasar.hpatient.model.litePalmodel.DailyItemInfodb;
import com.quasar.hpatient.model.litePalmodel.Dailyitemtypedb;
import com.quasar.hpatient.model.litePalmodel.DefaultInspectioninfodb;
import com.quasar.hpatient.model.litePalmodel.DepartMentInfodb;
import com.quasar.hpatient.model.litePalmodel.DiagnoseInfodb;
import com.quasar.hpatient.model.litePalmodel.DimDailyItemInfodb;
import com.quasar.hpatient.model.litePalmodel.DiseaseInfodb;
import com.quasar.hpatient.model.litePalmodel.DiseaseTypedb;
import com.quasar.hpatient.model.litePalmodel.DoseInfodb;
import com.quasar.hpatient.model.litePalmodel.DoseModedb;
import com.quasar.hpatient.model.litePalmodel.DosePerioddb;
import com.quasar.hpatient.model.litePalmodel.DurationInfodb;
import com.quasar.hpatient.model.litePalmodel.HospitalInfodb;
import com.quasar.hpatient.model.litePalmodel.InspectionDetailInfodb;
import com.quasar.hpatient.model.litePalmodel.InspectionInfodb;
import com.quasar.hpatient.model.litePalmodel.InspectionItemInfodb;
import com.quasar.hpatient.model.litePalmodel.InspectionTypeInfodb;
import com.quasar.hpatient.model.litePalmodel.KidneySourceTypedb;
import com.quasar.hpatient.model.litePalmodel.MedicineInfodb;
import com.quasar.hpatient.model.litePalmodel.MedicineTypedb;
import com.quasar.hpatient.model.litePalmodel.PositonInfodb;
import com.quasar.hpatient.model.litePalmodel.TroubleInfodb;
import com.quasar.hpatient.model.medicalmodel.AerainfoData;
import com.quasar.hpatient.model.medicalmodel.BloodTypeData;
import com.quasar.hpatient.model.medicalmodel.BodyinfoData;
import com.quasar.hpatient.model.medicalmodel.DailyiteminfoData;
import com.quasar.hpatient.model.medicalmodel.DailyitemtypeBean;
import com.quasar.hpatient.model.medicalmodel.DefaultInspectioninfoData;
import com.quasar.hpatient.model.medicalmodel.DepartmentinfoData;
import com.quasar.hpatient.model.medicalmodel.DiagnoseinfoData;
import com.quasar.hpatient.model.medicalmodel.DimDailyItemInfoData;
import com.quasar.hpatient.model.medicalmodel.DiseaseData;
import com.quasar.hpatient.model.medicalmodel.DiseasetypeData;
import com.quasar.hpatient.model.medicalmodel.DoseModeData;
import com.quasar.hpatient.model.medicalmodel.DosePeriodData;
import com.quasar.hpatient.model.medicalmodel.DoseinfoData;
import com.quasar.hpatient.model.medicalmodel.DurationinfoData;
import com.quasar.hpatient.model.medicalmodel.HospitalData;
import com.quasar.hpatient.model.medicalmodel.InspectionInfoData;
import com.quasar.hpatient.model.medicalmodel.InspectionItemInfoData;
import com.quasar.hpatient.model.medicalmodel.InspectionTypeInfoData;
import com.quasar.hpatient.model.medicalmodel.InspectiondetailinfoData;
import com.quasar.hpatient.model.medicalmodel.KidneySourceTypeData;
import com.quasar.hpatient.model.medicalmodel.MedicineinfoData;
import com.quasar.hpatient.model.medicalmodel.MedicinetypeData;
import com.quasar.hpatient.model.medicalmodel.PositionData;
import com.quasar.hpatient.model.medicalmodel.TroubleinfoData;
import com.quasar.hpatient.model.medicalmodel.VersionData;
import com.quasar.hpatient.network.ApiBasicData;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.litepal.crud.DataSupport;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;

/**
 * author :
 * Date: 2017/9/27 0027
 * View:
 */

public class SynchronizationData {
    //请求日常项目检查项
    public static void DayRecord() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DAILYITEMINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                //HttpResult类存在构造函数时会报错
                HttpResult<DailyiteminfoData> dailyiteminfo = JSON.parseObject(response, new TypeReference<HttpResult<DailyiteminfoData>>() {
                });
                int num = dailyiteminfo.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<DailyItemInfodb> db = DataSupport.where("primaryid=?", dailyiteminfo.getData().get(i).getId() + "").find(DailyItemInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("name", dailyiteminfo.getData().get(i).getName());
                            values.put("typeid", dailyiteminfo.getData().get(i).getTypeid());
                            values.put("name_en", dailyiteminfo.getData().get(i).getName_en());
                            values.put("short_name_en", dailyiteminfo.getData().get(i).getShort_name_en());
                            values.put("dimensionid", dailyiteminfo.getData().get(i).getDimensionid());
                            values.put("logType", dailyiteminfo.getData().get(i).getLogtype());
                            values.put("standard", dailyiteminfo.getData().get(i).getStandard());
                            values.put("description", dailyiteminfo.getData().get(i).getDescription());
                            values.put("createTime", dailyiteminfo.getData().get(i).getCreatetime() + "");
                            values.put("lastEditTime", dailyiteminfo.getData().get(i).getLastedittime() + "");
                            values.put("status",dailyiteminfo.getData().get(i).getStatus());
                            values.put("version",dailyiteminfo.getData().get(i).getVersion());
                            DataSupport.update(DailyItemInfodb.class, values, db.get(0).getId());
                        } else {

                            DailyItemInfodb dataBean = new DailyItemInfodb(
                                    1,
                                    dailyiteminfo.getData().get(i).getId(),
                                    dailyiteminfo.getData().get(i).getName(),
                                    dailyiteminfo.getData().get(i).getName_en(),
                                    dailyiteminfo.getData().get(i).getShort_name_en(),
                                    dailyiteminfo.getData().get(i).getDimensionid(),
                                    dailyiteminfo.getData().get(i).getLogtype(),
                                    dailyiteminfo.getData().get(i).getStandard(),
                                    dailyiteminfo.getData().get(i).getDescription(),
                                    dailyiteminfo.getData().get(i).getCreatetime(),
                                    dailyiteminfo.getData().get(i).getLastedittime(),
                                    dailyiteminfo.getData().get(i).getTypeid(),
                                    dailyiteminfo.getData().get(i).getStatus(),
                                    dailyiteminfo.getData().get(i).getVersion()

                            );
                            dataBean.save();
                        }
                    }
                }
            }
        });
    }

    //请求医院
    public static void HospitalUpdate() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.HOSPITALINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {

                HttpResult<HospitalData> hospitalData = JSON.parseObject(response, new TypeReference<HttpResult<HospitalData>>() {
                });


                int num = hospitalData.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<HospitalInfodb> db = DataSupport.where("primaryid=?", hospitalData.getData().get(i).getId() + "").find(HospitalInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("Name", hospitalData.getData().get(i).getName());
                            cv.put("cover", hospitalData.getData().get(i).getCover());
                            cv.put("provinceid", hospitalData.getData().get(i).getProvinceid());
                            cv.put("cityid", hospitalData.getData().get(i).getCityid());
                            cv.put("regionid", hospitalData.getData().get(i).getRegionid());
                            cv.put("addr", hospitalData.getData().get(i).getAddr());
                            cv.put("officephone", hospitalData.getData().get(i).getOfficephone());
                            cv.put("linkman", hospitalData.getData().get(i).getLinkman());
                            cv.put("status", hospitalData.getData().get(i).getStatus());
                            cv.put("description", hospitalData.getData().get(i).getDescription());
                            cv.put("createtime", hospitalData.getData().get(i).getCreatetime() + "");
                            cv.put("lastedittime", hospitalData.getData().get(i).getLastedittime() + "");
                            cv.put("version",hospitalData.getData().get(i).getVersion());
                            DataSupport.update(HospitalInfodb.class, cv, db.get(0).getId());
                        } else {
                            HospitalInfodb hospitalInfoDB = new HospitalInfodb(
                                    1,
                                    hospitalData.getData().get(i).getId(),
                                    hospitalData.getData().get(i).getName(),
                                    hospitalData.getData().get(i).getCover(),
                                    hospitalData.getData().get(i).getProvinceid(),
                                    hospitalData.getData().get(i).getCityid(),
                                    hospitalData.getData().get(i).getRegionid(),
                                    hospitalData.getData().get(i).getAddr(),
                                    hospitalData.getData().get(i).getOfficephone(),
                                    hospitalData.getData().get(i).getLinkman(),
                                    hospitalData.getData().get(i).getStatus(),
                                    hospitalData.getData().get(i).getDescription(),
                                    hospitalData.getData().get(i).getCreatetime(),
                                    hospitalData.getData().get(i).getLastedittime(),
                                    hospitalData.getData().get(i).getVersion());
                            hospitalInfoDB.save();
                        }
                    }
                }
            }
        });
    }

    //数据库表版本信息
    public static void VersionUpdate() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.BASEINFOVERSION).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {

                HttpResult<VersionData> versionData = JSON.parseObject(response, new TypeReference<HttpResult<VersionData>>() {
                });

                int num = versionData.getData().size();


                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<BaseInfoVersiondb> baseInfo = DataSupport.where("primaryid=?", versionData.getData().get(i).getId() + "").find(BaseInfoVersiondb.class);
                        if (baseInfo != null && baseInfo.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("name", versionData.getData().get(i).getName());
                            values.put("version", versionData.getData().get(i).getVersion());
                            values.put("updateTime", versionData.getData().get(i).getUpdatetime() + "");
                            DataSupport.update(BaseInfoVersiondb.class, values, baseInfo.get(0).getId());
                        } else {
                            BaseInfoVersiondb Version = new BaseInfoVersiondb(
                                    1,
                                    versionData.getData().get(i).getId(),
                                    versionData.getData().get(i).getName(),
                                    versionData.getData().get(i).getVersion(),
                                    versionData.getData().get(i).getUpdatetime());
                            Version.save();
                        }
                    }
                }
            }
        });
    }

    //根据数据表信息检测是否有数据更新
    public static void UpdateJudge() {
        final List<BaseInfoVersiondb> VersionDB = DataSupport.findAll(BaseInfoVersiondb.class);

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.BASEINFOVERSION).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {

                HttpResult<VersionData> versionData = JSON.parseObject(response, new TypeReference<HttpResult<VersionData>>() {
                });

                int num = versionData.getData().size();
                int size = VersionDB.size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        for (int j = 0; j < size; j++) {
                            if (versionData.getData().get(i).getName().equals(VersionDB.get(j).getName()) && versionData.getData().get(i).getVersion() > VersionDB.get(j).getVersion()) {
                                UpdateTable(VersionDB.get(j).getName());
                                break;
                            }
                        }
                    }
                }
            }
        });
    }

    //查询呢血型信息
    public static void BloodType() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.BlOODTYPEINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<BloodTypeData> blood = JSON.parseObject(response, new TypeReference<HttpResult<BloodTypeData>>() {
                });
                int num = blood.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<BloodTypeInfodb> db = DataSupport.where("primaryid=?", blood.getData().get(i).getId() + "").find(BloodTypeInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", blood.getData().get(i).getName());
                            cv.put("description", blood.getData().get(i).getDescription());
                            cv.put("status",blood.getData().get(i).getStatus());
                            cv.put("version",blood.getData().get(i).getVersion());
                            DataSupport.update(BloodTypeInfodb.class, cv, db.get(0).getPrimaryid());
                        } else {
                            BloodTypeInfodb bl = new BloodTypeInfodb(
                                    1,
                                    blood.getData().get(i).getId(),
                                    blood.getData().get(i).getName(),
                                    blood.getData().get(i).getDescription(),
                                    blood.getData().get(i).getStatus(),
                                    blood.getData().get(i).getVersion()
                            );
                            bl.save();
                        }
                    }
                }
            }
        });
    }

    //查询身体信息
    public static void bodyInfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.BODYINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<BodyinfoData> bodyinfoBean = JSONArray.parseObject(response, new TypeReference<HttpResult<BodyinfoData>>() {
                });

                if (bodyinfoBean != null) {
                    int num = bodyinfoBean.getData().size();
                    if (num != 0) {
                        for (int i = 0; i < num; i++) {

                            List<BodyInfodb> cb = DataSupport.where("primaryid=?", bodyinfoBean.getData().get(i).getId() + "").find(BodyInfodb.class);
                            if (cb != null && cb.size() > 0) {

                                ContentValues cv = new ContentValues();
                                cv.put("name", bodyinfoBean.getData().get(i).getName());
                                cv.put("description", bodyinfoBean.getData().get(i).getDescription());
                                cv.put("status", bodyinfoBean.getData().get(i).getStatus());
                                cv.put("version", bodyinfoBean.getData().get(i).getVersion());
                                DataSupport.update(BaseInfoVersiondb.class, cv, cb.get(0).getId());
                            } else {
                                BodyInfodb bod = new BodyInfodb(
                                        1,
                                        bodyinfoBean.getData().get(i).getId(),
                                        bodyinfoBean.getData().get(i).getName(),
                                        bodyinfoBean.getData().get(i).getDescription(),
                                        bodyinfoBean.getData().get(i).getStatus(),
                                        bodyinfoBean.getData().get(i).getVersion()
                                );
                                bod.save();
                            }
                        }
                    }
                }
            }
        });

    }

    //查询职位信息PositionData
    public static void PositionData() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.POSITIONINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<PositionData> position = JSONArray.parseObject(response, new TypeReference<HttpResult<PositionData>>() {
                });
                int num = position.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<PositonInfodb> db = DataSupport.where("primaryid=?", position.getData().get(i).getId() + "").find(PositonInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", position.getData().get(i).getName());
                            cv.put("pid", position.getData().get(i).getPid());
                            cv.put("description", position.getData().get(i).getDescription());
                            cv.put("status",position.getData().get(i).getStatus());
                            cv.put("version",position.getData().get(i).getVersion());

                            DataSupport.update(PositonInfodb.class, cv, db.get(0).getId());
                        } else {
                            PositonInfodb DB = new PositonInfodb(
                                    1,
                                    position.getData().get(i).getId(),
                                    position.getData().get(i).getName(),
                                    position.getData().get(i).getPid(),
                                    position.getData().get(i).getDescription(),
                                    position.getData().get(i).getStatus(),
                                    position.getData().get(i).getVersion());

                            DB.save();
                        }
                    }
                }
            }
        });
    }

    //查询药品类型信息
    public static void Medicinetype() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.MEDICINETYPE).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<MedicinetypeData> medicine = JSONArray.parseObject(response, new TypeReference<HttpResult<MedicinetypeData>>() {
                });
                int num = medicine.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<MedicineTypedb> db = DataSupport.where("primaryid=?", medicine.getData().get(i).getId() + "").find(MedicineTypedb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", medicine.getData().get(i).getName());
                            cv.put("description", medicine.getData().get(i).getDescription());
                            DataSupport.update(MedicineTypedb.class, cv, db.get(0).getId());
                        } else {
                            MedicineTypedb TypeDB = new MedicineTypedb(
                                    1,
                                    medicine.getData().get(i).getId(),
                                    medicine.getData().get(i).getName(),
                                    medicine.getData().get(i).getDescription());
                            TypeDB.save();
                        }
                    }
                }
            }
        });
    }

    //查询药品信息
    public static void Medicineinfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.MEDICINEINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<MedicineinfoData> medicine = JSONArray.parseObject(response, new TypeReference<HttpResult<MedicineinfoData>>() {
                });
                int num = medicine.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<MedicineInfodb> db = MedicineInfodb.where("primaryid=?", medicine.getData().get(i).getId() + "").find(MedicineInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("typeid", medicine.getData().get(i).getTypeid());
                            values.put("typename", medicine.getData().get(i).getTypename());
                            values.put("name", medicine.getData().get(i).getTypeid());
                            values.put("cover", medicine.getData().get(i).getTypeid());
                            values.put("name_en", medicine.getData().get(i).getTypeid());
                            values.put("short_name_en", medicine.getData().get(i).getTypeid());
                            values.put("doses", medicine.getData().get(i).getTypeid());
                            values.put("content", medicine.getData().get(i).getTypeid());
                            values.put("dimension", medicine.getData().get(i).getTypeid());
                            values.put("packages", medicine.getData().get(i).getTypeid());
                            values.put("usedesc", medicine.getData().get(i).getTypeid());
                            values.put("description", medicine.getData().get(i).getTypeid());
                            values.put("status", medicine.getData().get(i).getTypeid());
                            values.put("version", medicine.getData().get(i).getTypeid());
                            DataSupport.update(MedicineInfodb.class, values, db.get(0).getId());
                        } else {
                            MedicineInfodb medicineInfoDB = new MedicineInfodb(
                            1,
                                    medicine.getData().get(i).getId(),
                                    medicine.getData().get(i).getTypeid(),
                                    medicine.getData().get(i).getTypename(),
                                    medicine.getData().get(i).getName(),
                                    medicine.getData().get(i).getCover(),
                                    medicine.getData().get(i).getName_en(),
                                    medicine.getData().get(i).getShort_name_en(),
                                    medicine.getData().get(i).getDose(),
                                    medicine.getData().get(i).getContent(),
                                    medicine.getData().get(i).getDimension(),
                                    medicine.getData().get(i).getPackages(),
                                    medicine.getData().get(i).getUsedesc(),
                                    medicine.getData().get(i).getDescription(),
                                    medicine.getData().get(i).getStatus(),
                                    medicine.getData().get(i).getVersion());

                            medicineInfoDB.save();
                        }
                    }
                }
            }
        });
    }

    //查询科室信息DepartMentInfoDB
    public static void Departmentinfo() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DEPARTMENTINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DepartmentinfoData> depart = JSONArray.parseObject(response, new TypeReference<HttpResult<DepartmentinfoData>>() {
                });
                int num = depart.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {


                        List<DepartMentInfodb> db = DataSupport.where("primaryid=?", depart.getData().get(i).getId() + "").find(DepartMentInfodb.class);
                        if (db != null && db.size() > 0) {

                            ContentValues cv = new ContentValues();
                            cv.put("pid", depart.getData().get(i).getPid());
                            cv.put("level", depart.getData().get(i).getLevel());
                            cv.put("name", depart.getData().get(i).getName());
                            cv.put("description", depart.getData().get(i).getDescription());
                            cv.put("status",depart.getData().get(i).getStatus());
                            cv.put("version",depart.getData().get(i).getVersion());
                            DataSupport.update(DepartMentInfodb.class, cv, db.get(0).getId());
                        } else {
                            DepartMentInfodb departMentInfoDB = new DepartMentInfodb(
                                    1,
                                    depart.getData().get(i).getId(),
                                    depart.getData().get(i).getPid(),
                                    depart.getData().get(i).getLevel(),
                                    depart.getData().get(i).getName(),
                                    depart.getData().get(i).getDescription(),
                                    depart.getData().get(i).getStatus(),
                                    depart.getData().get(i).getVersion());
                            departMentInfoDB.save();
                        }

                    }
                }
            }
        });
    }

    //查询不适时长信息
    public static void Durationinfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DURATIONINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DurationinfoData> duration = JSONArray.parseObject(response, new TypeReference<HttpResult<DurationinfoData>>() {
                });
                int num = duration.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<DurationInfodb> db = DataSupport.where("primaryid=?", duration.getData().get(i).getId() + "").find(DurationInfodb.class);

                        if (db != null && db.size() > 0) {

                            ContentValues cv = new ContentValues();
                            cv.put("name", duration.getData().get(i).getName());
                            cv.put("description", duration.getData().get(i).getDescription());
                            DataSupport.update(DurationInfodb.class, cv, db.get(0).getId());

                        } else {
                            DurationInfodb durationInfoDB = new DurationInfodb(
                                    1,
                                    duration.getData().get(i).getId(),
                                    duration.getData().get(i).getName(),
                                    duration.getData().get(i).getDescription());
                            durationInfoDB.save();
                        }

                    }
                }
            }
        });
    }

    //查询不适症状信息
    public static void Troubleinfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.TROUBLEINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<TroubleinfoData> trouble = JSONArray.parseObject(response, new TypeReference<HttpResult<TroubleinfoData>>() {
                });
                int num = trouble.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<TroubleInfodb> db = DataSupport.where("primaryid=?", trouble.getData().get(i).getId() + "").find(TroubleInfodb.class);
                        if (db != null && db.size() > 0) {

                            ContentValues cv = new ContentValues();
                            cv.put("name", trouble.getData().get(i).getName());
                            cv.put("description", trouble.getData().get(i).getDescription());
                            DataSupport.update(TroubleInfodb.class, cv, db.get(0).getId());
                        } else {
                            TroubleInfodb troubleInfoDB = new TroubleInfodb(
                                    1,
                                    trouble.getData().get(i).getId(),
                                    trouble.getData().get(i).getName(),
                                    trouble.getData().get(i).getDescription());
                            troubleInfoDB.save();
                        }
                    }
                }
            }
        });
    }

    //查询常见疾病信息
    public static void CommonDisease() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DISEASEINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DiseaseData> diseaseData = JSONArray.parseObject(response, new TypeReference<HttpResult<DiseaseData>>() {
                });
                int num = diseaseData.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<DiseaseInfodb> db = DataSupport.where("primaryid=?", diseaseData.getData().get(i).getId() + "").find(DiseaseInfodb.class);

                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", diseaseData.getData().get(i).getName());
                            cv.put("level", diseaseData.getData().get(i).getLevel());
                            cv.put("typeId", diseaseData.getData().get(i).getTypeid());
                            cv.put("cover", diseaseData.getData().get(i).getCover());
                            cv.put("departmentId", diseaseData.getData().get(i).getDepartmentid());
                            cv.put("bodyId", diseaseData.getData().get(i).getBodyid());
                            cv.put("description", diseaseData.getData().get(i).getDescription());
                            DataSupport.update(DiseaseInfodb.class, cv, db.get(0).getId());
                        }

                        DiseaseInfodb diseaseInfoDB = new DiseaseInfodb(
                                1,
                                diseaseData.getData().get(i).getId(),
                                diseaseData.getData().get(i).getName(),
                                diseaseData.getData().get(i).getLevel(),
                                diseaseData.getData().get(i).getTypeid(),
                                diseaseData.getData().get(i).getCover(),
                                diseaseData.getData().get(i).getDepartmentid(),
                                diseaseData.getData().get(i).getBodyid(),
                                diseaseData.getData().get(i).getDescription()
                        );

                        diseaseInfoDB.save();
                    }
                }
            }
        });
    }

    //查询药品剂量名称
    public static void DrugsDose() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DOSEINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DoseinfoData> doseinfoData = JSONArray.parseObject(response, new TypeReference<HttpResult<DoseinfoData>>() {
                });
                int num = doseinfoData.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<DoseInfodb> db = DataSupport.where("primary=?", doseinfoData.getData().get(i).getId() + "").find(DoseInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("name", doseinfoData.getData().get(i).getName());
                            values.put("value", doseinfoData.getData().get(i).getValue());
                            values.put("dosenameid", doseinfoData.getData().get(i).getDosenameid());
                            values.put("contentid", doseinfoData.getData().get(i).getContentid());
                            values.put("description", doseinfoData.getData().get(i).getDescription());
                            DataSupport.update(DoseInfodb.class, values, db.get(0).getId());
                        } else {
                            DoseInfodb diseaseInfoDB = new DoseInfodb(
                                    1,
                                    doseinfoData.getData().get(i).getId(),
                                    doseinfoData.getData().get(i).getName(),
                                    doseinfoData.getData().get(i).getValue(),
                                    doseinfoData.getData().get(i).getDosenameid(),
                                    doseinfoData.getData().get(i).getContentid(),
                                    doseinfoData.getData().get(i).getDescription()
                            );
                            diseaseInfoDB.save();
                        }
                    }
                }
            }
        });
    }

    //查询肾来源类型
    public static void Kidneysourcetype() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.KIDNEYSOURCETYPE).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<KidneySourceTypeData> TypeData = JSONArray.parseObject(response, new TypeReference<HttpResult<KidneySourceTypeData>>() {
                });
                int num = TypeData.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<KidneySourceTypedb> db = DataSupport.where("primaryid=?", TypeData.getData().get(i).getId() + "").find(KidneySourceTypedb.class);

                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", TypeData.getData().get(i).getName());
                            cv.put("description", TypeData.getData().get(i).getDescription());
                            cv.put("status",TypeData.getData().get(i).getStatus());
                            cv.put("version",TypeData.getData().get(i).getVersion());
                            DataSupport.update(KidneySourceTypedb.class, cv, db.get(0).getId());
                        }

                        KidneySourceTypedb kidney = new KidneySourceTypedb(
                                1,
                                TypeData.getData().get(i).getId(),
                                TypeData.getData().get(i).getName(),
                                TypeData.getData().get(i).getDescription(),
                                TypeData.getData().get(i).getStatus(),
                                TypeData.getData().get(i).getVersion()
                        );
                        kidney.save();
                    }
                }
            }
        });

    }

    //查询检查单检查项目信息
    public static void InspectionItem() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.INSPECTIONITEMINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<InspectionItemInfoData> inspection = JSONArray.parseObject(response, new TypeReference<HttpResult<InspectionItemInfoData>>() {
                });
                int num = inspection.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<InspectionItemInfodb> db = DataSupport.where("primaryid =?", inspection.getData().get(i).getId() + "").find(InspectionItemInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", inspection.getData().get(i).getName());
                            cv.put("name_en", inspection.getData().get(i).getName_en());
                            cv.put("short_name_en", inspection.getData().get(i).getShort_Name_en());
                            cv.put("dimensionId", inspection.getData().get(i).getDimensionId());
                            cv.put("standard", inspection.getData().get(i).getStandard());
                            cv.put("critical", inspection.getData().get(i).getCritical());
                            cv.put("boundary", inspection.getData().get(i).getBoundary());
                            cv.put("description", inspection.getData().get(i).getDescription());
                            cv.put("version", inspection.getData().get(i).getVersion());
                            cv.put("status", inspection.getData().get(i).getStatus());
                            DataSupport.update(InspectionItemInfodb.class, cv, db.get(0).getId());
                        } else {
                            InspectionItemInfodb inspectionItem = new InspectionItemInfodb(
                                    1,
                                    inspection.getData().get(i).getId(),
                                    inspection.getData().get(i).getName(),
                                    inspection.getData().get(i).getName_en(),
                                    inspection.getData().get(i).getShort_Name_en(),
                                    inspection.getData().get(i).getDimensionId(),
                                    inspection.getData().get(i).getStandard(),
                                    inspection.getData().get(i).getCritical(),
                                    inspection.getData().get(i).getBoundary(),
                                    inspection.getData().get(i).getDescription(),
                                    inspection.getData().get(i).getVersion(),
                                    inspection.getData().get(i).getStatus());
                            inspectionItem.save();
                        }
                    }
                }
            }
        });
    }

    //查询服药周期信息
    public static void DosePeriodData() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DOSEPERIOD).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DosePeriodData> dose = JSONArray.parseObject(response, new TypeReference<HttpResult<DosePeriodData>>() {
                });
                int num = dose.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<DosePerioddb> db = DataSupport.where("primaryid=?", dose.getData().get(i).getId() + "").find(DosePerioddb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("name", dose.getData().get(i).getName());
                            cv.put("description", dose.getData().get(i).getDescription());
                            cv.put("status",dose.getData().get(i).getStatus());
                            cv.put("version",  dose.getData().get(i).getVersion());
                            cv.put("timelen",  dose.getData().get(i).getTimelen());
                            DataSupport.update(KidneySourceTypedb.class, cv, db.get(0).getId());
                        } else {
                            DosePerioddb inspectionItem = new DosePerioddb(
                                    1,
                                    dose.getData().get(i).getId(),
                                    dose.getData().get(i).getName(),
                                    dose.getData().get(i).getDescription(),
                                    dose.getData().get(i).getStatus(),
                                    dose.getData().get(i).getVersion(),
                                    dose.getData().get(i).getTimelen()
                            );
                            inspectionItem.save();
                        }
                    }
                }
            }
        });
    }

    //查询疾病分类信息DiseaseTypeDB
    public static void Diseasetype() {

        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DISEASETYPE).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DiseasetypeData> disease = JSONArray.parseObject(response, new TypeReference<HttpResult<DiseasetypeData>>() {
                });
                int num = disease.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<DiseaseTypedb> db = DataSupport.where("primaryid=?", disease.getData().get(i).getId() + "").find(DiseaseTypedb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("Typename", disease.getData().get(i).getTypename());
                            cv.put("Desc", disease.getData().get(i).getDesc());
                            DataSupport.update(DiseaseTypedb.class, cv, db.get(0).getId());
                        } else {
                            DiseaseTypedb inspectionItem = new DiseaseTypedb(
                                    1,
                                    disease.getData().get(i).getId(),
                                    disease.getData().get(i).getTypename(),
                                    disease.getData().get(i).getDesc()
                            );

                            inspectionItem.save();
                        }
                    }
                }
            }
        });
    }

    //查询检查项目量纲名称信息
    public static void Dimdailyiteminfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DIMDAILYITEMINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DimDailyItemInfoData> dimDaily = JSONArray.parseObject(response, new TypeReference<HttpResult<DimDailyItemInfoData>>() {
                });
                int num = dimDaily.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<DimDailyItemInfodb> dim = DataSupport.where("primaryid=?", dimDaily.getData().get(i).getId() + "").find(DimDailyItemInfodb.class);
                        if (dim != null && dim.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("name", dimDaily.getData().get(i).getName());
                            values.put("description", dimDaily.getData().get(i).getDescription());
                            values.put("status",dimDaily.getData().get(i).getStatus());
                            values.put("version",dimDaily.getData().get(i).getVersion());
                            DataSupport.update(DimDailyItemInfodb.class, values, dim.get(0).getId());
                        } else {
                            DimDailyItemInfodb inspectionItem = new DimDailyItemInfodb(
                                    1,
                                    dimDaily.getData().get(i).getId(),
                                    dimDaily.getData().get(i).getName(),
                                    dimDaily.getData().get(i).getDescription(),
                                    dimDaily.getData().get(i).getStatus(),
                                    dimDaily.getData().get(i).getVersion()
                            );
                            inspectionItem.save();
                        }
                    }
                }
            }
        });
    }

    /**
     * 服药方式
     *
     * @param
     * @return
     */
    public static void DoseModeDB() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.DOSEMODE).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<DoseModeData> doseModeData = JSONArray.parseObject(response, new TypeReference<HttpResult<DoseModeData>>() {
                });
                int num = doseModeData.getData().size();

                List<DoseModedb> DoseModeDBList = new ArrayList<>();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        DoseModedb doseModeDB = new DoseModedb(
                                1,
                                doseModeData.getData().get(i).getId(),
                                doseModeData.getData().get(i).getName(),
                                doseModeData.getData().get(i).getHowto(),
                                doseModeData.getData().get(i).getFrequency(),
                                doseModeData.getData().get(i).getDescription()
                        );
                        DoseModeDBList.add(doseModeDB);
                    }
                }
                DataSupport.saveAll(DoseModeDBList);
            }
        });
    }

    /**
     * 日常检查单分类信息
     */
    public static void checklistType() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.Inspectiontypeinfo).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<InspectionTypeInfoData> inspectionTypeInfoData = JSONArray.parseObject(response, new TypeReference<HttpResult<InspectionTypeInfoData>>() {
                });
                int num = inspectionTypeInfoData.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<InspectionTypeInfodb> db = DataSupport.where("primaryid=?", inspectionTypeInfoData.getData().get(i).getId() + "").find(InspectionTypeInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("hospitalid", inspectionTypeInfoData.getData().get(i).getHospitalid());
                            cv.put("name", inspectionTypeInfoData.getData().get(i).getName());
                            cv.put("description", inspectionTypeInfoData.getData().get(i).getDescription());
                            DataSupport.update(InspectionTypeInfodb.class, cv, db.get(0).getId());
                        } else {
                            InspectionTypeInfodb InfoDB = new InspectionTypeInfodb(
                                    1,
                                    inspectionTypeInfoData.getData().get(i).getId(),
                                    inspectionTypeInfoData.getData().get(i).getName(),
                                    inspectionTypeInfoData.getData().get(i).getHospitalid(),
                                    inspectionTypeInfoData.getData().get(i).getDescription()
                            );
                            InfoDB.save();
                        }
                    }
                }
            }
        });
    }

    /**
     * 检查单信息
     * InspectionInfoDB
     * InspectionInfoData
     */
    public static void checklist() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.Inspectioninfo).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<InspectionInfoData> inspection = JSONArray.parseObject(response, new TypeReference<HttpResult<InspectionInfoData>>() {
                });
                int num = inspection.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<InspectionInfodb> db = InspectionInfodb.where("primaryid=?", inspection.getData().get(i).getId() + "").find(InspectionInfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("name", inspection.getData().get(i).getName());
                            values.put("userId", inspection.getData().get(i).getUserId());
                            values.put("userType", inspection.getData().get(i).getTypeid());
                            values.put("typeid", inspection.getData().get(i).getTypeid());
                            values.put("sort", inspection.getData().get(i).getSort());
                            values.put("description", inspection.getData().get(i).getDescription());
                            values.put("version", inspection.getData().get(i).getVersion());
                            values.put("status", inspection.getData().get(i).getStatus());
                            DataSupport.update(InspectionInfodb.class, values, db.get(0).getId());
                        } else {
                            InspectionInfodb insp = new InspectionInfodb(
                                    1,
                                    inspection.getData().get(i).getId(),
                                    inspection.getData().get(i).getName(),
                                    inspection.getData().get(i).getUserId(),
                                    inspection.getData().get(i).getUserType(),
                                    inspection.getData().get(i).getTypeid(),
                                    inspection.getData().get(i).getSort(),
                                    inspection.getData().get(i).getDescription(),
                                    inspection.getData().get(i).getVersion(),
                                    inspection.getData().get(i).getStatus());
                            insp.save();
                        }
                    }
                }
            }
        });
    }

    /**
     * 查询检查单详情
     * <p>
     * InspectionDetailInfoDB
     * <p>
     * InspectiondetailinfoData
     */
    public static void Inspectiondetailinfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.Inspectiondetailinfo).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<InspectiondetailinfoData> inspectiondetailin = JSONArray.parseObject(response, new TypeReference<HttpResult<InspectiondetailinfoData>>() {
                });
                int num = inspectiondetailin.getData().size();
                if (num != 0) {
                    for (int i = 0; i < num; i++) {

                        List<InspectionDetailInfodb> DB = DataSupport.where(" primaryid=?", inspectiondetailin.getData().get(i).getId() + "").find(InspectionDetailInfodb.class);
                        if (DB != null && DB.size() > 0) {
                            ContentValues values = new ContentValues();
                            values.put("inspectionid", inspectiondetailin.getData().get(i).getInspectionid());
                            values.put("itemid", inspectiondetailin.getData().get(i).getItemid());
                            values.put("version", inspectiondetailin.getData().get(i).getVersion());
                            values.put("status", inspectiondetailin.getData().get(i).getStatus());
                            values.put("defaultSelect", inspectiondetailin.getData().get(i).getStatus());
                            DataSupport.update(InspectionDetailInfodb.class, values, DB.get(0).getId());
                        } else {
                            InspectionDetailInfodb insp = new InspectionDetailInfodb(
                                    1,
                                    inspectiondetailin.getData().get(i).getId(),
                                    inspectiondetailin.getData().get(i).getInspectionid(),
                                    inspectiondetailin.getData().get(i).getItemid(),
                                    inspectiondetailin.getData().get(i).getVersion(),
                                    inspectiondetailin.getData().get(i).getStatus(),
                                    inspectiondetailin.getData().get(i).getDefaultSelect(),
                                    inspectiondetailin.getData().get(i).getSort()
                            );
                            insp.save();
                        }
                    }
                }
            }
        });
    }

    /**
     * 查询地理信息
     */
    public static void Aerainfo() {
        OkHttpUtils.get().url(ApiBasicData.BASICDATAURL + ApiBasicData.AERAINFO).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(String response, int id) {
                HttpResult<AerainfoData> aerainfoData = JSONArray.parseObject(response, new TypeReference<HttpResult<AerainfoData>>() {
                });
                int num = aerainfoData.getData().size();

                if (num != 0) {
                    for (int i = 0; i < num; i++) {
                        List<Aerainfodb> db = DataSupport.where("primaryid=?", aerainfoData.getData().get(i).getAerainfo_id() + "").find(Aerainfodb.class);
                        if (db != null && db.size() > 0) {
                            ContentValues cv = new ContentValues();
                            cv.put("code", aerainfoData.getData().get(i).getAerainfo_code());
                            cv.put("name", aerainfoData.getData().get(i).getAerainfo_name());
                            cv.put("pid", aerainfoData.getData().get(i).getParent_id());
                            cv.put("level", aerainfoData.getData().get(i).getAerainfo_level());
                            cv.put("Name_en", aerainfoData.getData().get(i).getAerainfo_name_en());
                            cv.put("Short_name_en", aerainfoData.getData().get(i).getAerainfo_shortname_en());
                            DataSupport.update(Aerainfodb.class, cv, db.get(0).getId());
                        } else {
                            Aerainfodb aeraInfoDB = new Aerainfodb(
                                    1,
                                    aerainfoData.getData().get(i).getAerainfo_id(),
                                    aerainfoData.getData().get(i).getAerainfo_code(),
                                    aerainfoData.getData().get(i).getAerainfo_name(),
                                    aerainfoData.getData().get(i).getParent_id(),
                                    aerainfoData.getData().get(i).getAerainfo_level(),
                                    aerainfoData.getData().get(i).getAerainfo_order(),
                                    aerainfoData.getData().get(i).getAerainfo_name_en(),
                                    aerainfoData.getData().get(i).getAerainfo_shortname_en()
                            );
                            aeraInfoDB.save();
                        }
                    }
                }
            }
        });
    }

    /**
     * 获取诊断信息
     */
    //诊断信息
    public static void GetDiagnoseinfo() {
        OkHttpUtils
                .get()
                .url(ApiBasicData.BASICDATAURL + ApiBasicData.Diagnoseinfo)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        HttpResult<DiagnoseinfoData> diagnoseinfoBean = JSONArray.parseObject(response, new TypeReference<HttpResult<DiagnoseinfoData>>() {
                        });
                        List<DiagnoseInfodb> diagnoseInfos = new ArrayList<DiagnoseInfodb>();
                        for (int i = 0; i < diagnoseinfoBean.getData().size(); i++) {
                            DiagnoseInfodb diagnoseInfo = new DiagnoseInfodb(
                                    1,
                                    diagnoseinfoBean.getData().get(i).getId()
                                    , diagnoseinfoBean.getData().get(i).getMessage()
                                    , diagnoseinfoBean.getData().get(i).getDescription());
                            diagnoseInfos.add(diagnoseInfo);
                        }
                        DataSupport.saveAll(diagnoseInfos);
                    }
                });
    }

    /**
     * 根据医院更改化验项
     * <p>
     * <p>
     * CurrentUserSettings.produceUrl(Urls.LXT_DefaultInspection)
     */
    public static void defaultInspectionInfo() {
        OkHttpUtils
                .get()
                .url(ApiBasicData.BASICDATAURL + ApiBasicData.LXT_DefaultInspection)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        AnotherResult<DefaultInspectioninfoData> Inspectioninfo = JSONArray.parseObject(response, new TypeReference<AnotherResult<DefaultInspectioninfoData>>() {
                        });
                        for (int i = 0; i < Inspectioninfo.getList().size(); i++) {

                            List<DefaultInspectioninfodb> db = DefaultInspectioninfodb.where("id=?", Inspectioninfo.getList().get(i).getId() + "").find(DefaultInspectioninfodb.class);
                            if (db != null && db.size() > 0) {
                                ContentValues values = new ContentValues();
                                values.put("diseaseinfoId", Inspectioninfo.getList().get(i).getDiseaseinfoId());
                                values.put("hospitalId", Inspectioninfo.getList().get(i).getHospitalId());
                                values.put("inspectioninfoId", Inspectioninfo.getList().get(i).getInspectioninfoId());
                                values.put("descripation", Inspectioninfo.getList().get(i).getDescripation());
                                values.put("version",Inspectioninfo.getList().get(i).getVersion());
                                DataSupport.update(DefaultInspectioninfodb.class, values, Inspectioninfo.getList().get(i).getId());
                            } else {
                                DefaultInspectioninfodb defaultInspectioninfoDB = new DefaultInspectioninfodb(
                                        Inspectioninfo.getList().get(i).getId(),
                                        Inspectioninfo.getList().get(i).getDiseaseinfoId(),
                                        Inspectioninfo.getList().get(i).getHospitalId(),
                                        Inspectioninfo.getList().get(i).getInspectioninfoId(),
                                        Inspectioninfo.getList().get(i).getDescripation(),
                                        Inspectioninfo.getList().get(i).getVersion());
                                defaultInspectioninfoDB.save();
                            }

                        }
                    }
                });
    }

    /**
     * 获取检查单分类信息
     */
    public static void GetDailtemType() {
        OkHttpUtils
                .get()
                .url(ApiBasicData.BASICDATAURL + ApiBasicData.LXT_GetDailtemType)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {

                    }

                    @Override
                    public void onResponse(String response, int id) {
                        AnotherResult<DailyitemtypeBean> dailyitemtypeBean = JSONArray.parseObject(response, new TypeReference<AnotherResult<DailyitemtypeBean>>() {
                        });
                        if (dailyitemtypeBean.getList() != null) {
                            for (int i = 0; i < dailyitemtypeBean.getList().size(); i++) {
                                Dailyitemtypedb dailyitemtypeDB = DataSupport.find(Dailyitemtypedb.class, dailyitemtypeBean.getList().get(i).getId());
                                if (dailyitemtypeDB != null) {
                                    ContentValues cv = new ContentValues();
                                    cv.put("typename", dailyitemtypeBean.getList().get(i).getTypeName());
                                    cv.put("descs", dailyitemtypeBean.getList().get(i).getDesc());
                                    DataSupport.update(Dailyitemtypedb.class, cv, dailyitemtypeBean.getList().get(i).getId());
                                } else {
                                    Dailyitemtypedb DB = new Dailyitemtypedb(
                                            dailyitemtypeBean.getList().get(i).getId(),
                                            dailyitemtypeBean.getList().get(i).getTypeName(),
                                            dailyitemtypeBean.getList().get(i).getDesc());
                                    DB.save();
                                }
                            }
                        }
                    }
                });
    }

    //根据判断去更新那个表的数据
    public static void UpdateTable(String table) {

        switch (table) {
            case "hospitalinfo":
                HospitalUpdate();
                VersionUpdate();
                break;

            case "dailyiteminfo":
                DayRecord();
                VersionUpdate();
                break;

            //血型信息
            case "bloodtypeinfo":
                BloodType();
                VersionUpdate();
                break;

            //身体部位信息
            case "bodyinfo":
                bodyInfo();
                VersionUpdate();
                break;
            //职位信息
            case "positioninfo":
                PositionData();
                VersionUpdate();
                break;
            //药品类型信息
            case "medicinetype":
                Medicinetype();
                VersionUpdate();
                break;

            //药品信息Medicineinfo()
            case "medicineinfo":
                Medicineinfo();
                VersionUpdate();
                break;

            //科室信息
            case "departmentinfo":
                Departmentinfo();
                VersionUpdate();
                break;

            //查询不适时长信息
            case "durationinfo":
                Durationinfo();
                VersionUpdate();
                break;

            //查询不适症状信息
            case "troubleinfo":
                Troubleinfo();
                VersionUpdate();
                break;

            //查询常见疾病信息
            case "diseaseinfo":
                CommonDisease();
                VersionUpdate();
                break;

            //查询药品剂量名称
            case "doseinfo":
                DrugsDose();
                VersionUpdate();
                break;

            //查询肾来源类型
            case "kidneysourcetype":
                Kidneysourcetype();
                VersionUpdate();
                break;

            //检查单检查项目信息
            case "inspectioniteminfo":
                InspectionItem();
                VersionUpdate();
                break;

            //服药周期
            case "doseperiod":
                DosePeriodData();
                VersionUpdate();
                break;

            //查询疾病分类信息
            case "diseasetype":
                Diseasetype();
                VersionUpdate();
                break;

            //查询检查项目量纲名称信息
            case "dimdailyiteminfo":
                Dimdailyiteminfo();
                VersionUpdate();
                break;

            //服药方式获取
            case "dosemode":
                DataSupport.deleteAll(DoseModedb.class);
                DoseModeDB();
                VersionUpdate();
                break;

            //查询检查单分类信息
            case "inspectiontypeinfo":
                checklistType();
                VersionUpdate();
                break;
            //查询检查单信息
            case "inspectioninfo":
                checklist();
                VersionUpdate();
                break;

            case "inspectiondetailinfo":
                Inspectiondetailinfo();
                VersionUpdate();
                break;
            //获取诊断内容
            case "diagnoseinfo":
                DataSupport.deleteAll(DiagnoseInfodb.class);
                GetDiagnoseinfo();
                VersionUpdate();
                break;

            //获取医院检查项
            case "default_inspectioninfo":
                defaultInspectionInfo();
                VersionUpdate();
                break;

            //获取日常记录信息
            case "dailyitemtype":
                GetDailtemType();
                VersionUpdate();
                break;
        }
    }

}
